package com.huobao.shangjia_version.activitys;

import java.util.Map;

import org.simple.eventbus.EventBus;
import org.xutils.view.annotation.ViewInject;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.huobao.yunying.base.HuobaoBaseActivity;
import com.huobao.yunying.https.Http;
import com.huobao.yunying.https.HttpListener;
import com.huobao.yunying.https.HttpUtil;
import com.huobao.zhangying.R;

import android.view.View;
import android.widget.RadioButton;
import android.widget.Toast;

public class Act_Progect_Edit extends HuobaoBaseActivity {

	@ViewInject(R.id.rb_shangjia)
	private RadioButton rb_shangjia;
	@ViewInject(R.id.rb_xiajia)
	private RadioButton rb_xiajia;
	@ViewInject(R.id.rb_tuijian)
	private RadioButton rb_tuijian;
	@ViewInject(R.id.rb_notuijian)
	private RadioButton rb_notuijian;

	private String ids;

	@Override
	protected int getContentView() {
		// TODO Auto-generated method stub
		return R.layout.layout_progect_edit;
	}

	@Override
	protected String getTitleText() {
		// TODO Auto-generated method stub
		return getString(R.string.title_4);
	}

	@Override
	protected void init() {
		ids = getIntent().getStringExtra("ids");
	}

	public void onSubmitClick(View v) {
		Map<String, String> map = HttpUtil.getParams("app", "mygoods", "act", "edit", "id", ids, "sgcate_id",
				rb_shangjia.isChecked() ? "1" : "0", "recommended", rb_tuijian.isChecked() ? "1" : "0");
		Http.getInstant().sendRequest(context, map, new HttpListener() {
			
			@Override
			public void onHttpSuccess(String result) {
				JSONObject jsonObject = JSON.parseObject(result);
				Toast.makeText(context, jsonObject.getString("retval"), Toast.LENGTH_SHORT).show();
				EventBus.getDefault().post("", "refresh");
				finish();
			}
			
			@Override
			public void onHttpError(String error) {
				// TODO Auto-generated method stub
				
			}
		});
	}
}
